<%-- 
    Document   : Event
    Created on : 13-08-2014, 22:57:17
    Author     : NGOCLINH-PC
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="Data.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Data.Event"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<div class="primarysanpham">
    <div class="menusanpham">
        <div class="menusanpham1">
            <h2 style="padding: 10px; color: #999;">Management Event</h2>
            <hr />
            <form action="../Event" method="post" name="frmSearch" id="frmSearch">
                <ul>
                    <li style="float: left;"><a href="index.jsp?page=addEvent"><img src="../admin/image/Add.png" alt="add" width="98" height="32"/></a></li>
                    <!--<li><a href="home.php?prog=12&act=6"><img src="../../templates/admin/image/Delete.png" alt="delete" width="90" height="32"/></a></li>-->

                    <li class="loc" style="padding: 0; float: left;">Category: <select name='listmenuloc' style="min-width: 150px; height: 30px; background: #f5f5f5; border: none" class='listmenuloc'>
                            <option value="1">--All--</option>
                            <%
                                Category cte = new Category();
                                ArrayList<Category> aca = cte.CselectbyQuery(" AND Status=1");
                                if (aca.size() > 0) {
                                    for (int i = 0; i < aca.size(); i++) {
                                        Category categ = aca.get(i);

                                        out.print("<option value='" + categ.getCategoryID() + "'>" + categ.getCategoryName() + "</option>");

                                    }
                                }
                            %>
                        </select>
                    </li>
                    <li style="float: left;width: 200px;"><input style="width: 200px; height: 30px; background: #f5f5f5; border: none" type="text" name="txtSearch" id="txtSearch" placeholder="  Event name..." /></li>

                    <li style="float: left;"><input type="submit" name="btnSearch" style='background:  #00A8FF; border: none; width: 120px; height: 30px; color: #fff;' value="Search" /></li>
                </ul>
            </form>
        </div>
    </div>
    <div class="tablesanpham">
        <div class="tablesanpham1">
            <form action="" method="post" name="frm" id="frm">

                <table width="100%" border="1" cellspacing="0" cellpadding="4" id="mytable">
                    <tr>
                        <th scope="col">STT</th>

                        <th scope="col">Category</th>
                        <th scope="col">Event Name</th>
                        <th scope="col">Speakers</th>
                        <th scope="col">Address</th>
                        <th scope="col">Description</th>
                        <!--<th scope="col">Content</th>-->
                        <th scope="col">Price</th>
                        <th scope="col">Time Event</th>
                        <th scope="col">Deadline</th>
                        <th scope="col">Images</th>
                        <th scope="col">Status</th>
                        <th scope="col">Actions</th>
                    </tr>
                    <%
                        Event ct = new Event();
                        ArrayList<Event> a;
                        if (session.getAttribute("sstimkiem") == null || session.getAttribute("sstimkiem") == "") {
                            a = ct.ESelect();


                            int k = 1;
                            if (a.size() > 0) {
                                for (int i = 0; i < a.size(); i++) {
                                    Event cate = a.get(i);
                                    out.print("<tr>");
                                    out.print("<td>" + k++ + "</td>");

                                    Category c = new Category();
                                    ArrayList<Category> ac = c.CselectById(cate.CategoryID());
                                    for (int j = 0; j < ac.size(); j++) {
                                        Category ca = ac.get(j);
                                        out.print("<td>" + ca.getCategoryName() + "</td>");
                                    }

                                    out.print("<td>" + cate.getEventName() + "</td>");
                                    out.print("<td>" + cate.getSpeakers() + "</td>");
                                    out.print("<td>" + cate.getAddress() + "</td>");
                                    out.print("<td>" + cate.getDescription() + "</td>");
                                   // out.print("<td>" + cate.getContents() + "</td>");
                                    out.print("<td>" + cate.getPrice() + "</td>");
                                    out.print("<td>" + cate.getTimeEvent() + "</td>");
                                    out.print("<td>" + cate.getDeadline() + "</td>");
                                    out.print("<td><img src='../uploads/" + cate.getImages() + "' alt='" + cate.getEventName() + "' width='50' height='50'/></td>");
                                    if (cate.getStatus() == 1) {
                                        out.print("<td><img src='../admin/image/check.png' alt='check' /></td>");
                                    } else {
                                        out.print("<td><img src='../admin/image/No_check.png' alt='no_check' /></td>");
                                    }
                                    out.print("<td><span class='xoa'><a href='index.jsp?page=addEvent&EeventID=" + cate.getEventID() + "'><img src='../admin/image/editBtn.gif' alt='editBtn'  /></a>&nbsp;<a href='../Event?AeventID=" + cate.getEventID() + "' onclick='return confirm(\"Do you want delete!\")'><img src='../admin/image/deleteBtn.gif' alt='deleteBtn' /></a></span></td>");
                                    out.print("</tr>");
                                }
                            }
                        } else {
                            a = new Event().getArrEvent();
                            int k = 1;
                            if (a.size() > 0) {
                                for (int i = 0; i < a.size(); i++) {
                                    Event cate = a.get(i);
                                    out.print("<tr>");
                                    out.print("<td>" + k++ + "</td>");

                                    Category c = new Category();
                                    ArrayList<Category> ac = c.CselectById(cate.CategoryID());
                                    for (int j = 0; j < ac.size(); j++) {
                                        Category ca = ac.get(j);
                                        out.print("<td>" + ca.getCategoryName() + "</td>");
                                    }

                                    out.print("<td>" + cate.getEventName() + "</td>");
                                    out.print("<td>" + cate.getSpeakers() + "</td>");
                                    out.print("<td>" + cate.getAddress() + "</td>");
                                    out.print("<td>" + cate.getDescription() + "</td>");
                                    out.print("<td>" + cate.getContents() + "</td>");
                                    out.print("<td>" + cate.getPrice() + "</td>");
                                    out.print("<td>" + cate.getTimeEvent() + "</td>");
                                    out.print("<td>" + cate.getDeadline() + "</td>");
                                    out.print("<td><img src='../uploads/" + cate.getImages() + "' align='' width='50' height='50'  /></td>");
                                    if (cate.getStatus() == 1) {
                                        out.print("<td><img src='../admin/image/check.png' alt='check' /></td>");
                                    } else {
                                        out.print("<td><img src='../admin/image/No_check.png' alt='no_check' /></td>");
                                    }
                                    out.print("<td><span class='xoa'><a href='index.jsp?page=addEvent&EeventID=" + cate.getEventID() + "'><img src='../admin/image/editBtn.gif' alt='editBtn'  /></a>&nbsp;<a href='../Event?AeventID=" + cate.getEventID() + "' onclick='return confirm(\"Do you want delete!\")'><img src='../admin/image/deleteBtn.gif' alt='deleteBtn' /></a></span></td>");
                                    out.print("</tr>");
                                }
                            }
                            session.setAttribute("sstimkiem", "");
                        }
                    %>


                </table>
                <div class="pages">


                </div>
            </form>
        </div>
    </div>
</div>
